﻿FlyTalk.views.ColumnView = Ext.extend(Ext.Panel, {

  //  notesStore: Ext.emptyFn,
   // notesList: Ext.emptyFn,

    layout: 'fit',

    initComponent: function () {

        this.searchButton = new Ext.Button({
            text: 'Search',
            ui: 'action',
            handler: this.onSearch,
            scope: this
        });
		
		this.composeButton = new Ext.Button({
            text: 'Compose',
            ui: 'action',
            handler: this.onCompose,
            scope: this
        });
		
		/*

        this.tweetToolbar = new Ext.Toolbar({
            title: 'My Notes',
            items: [
                { xtype: 'spacer' },
                this.newButton
            ]
        });*/
		
			// Tweet toolbar
		this.tweetToolbar = new Ext.Toolbar({
			id: 'tweetToolbar',
			title: 'Talk',
			doc: top,
			layout: 'hbox',
			items: [
				{xtype: 'spacer'},
				this.searchButton,
				this.composeButton,
			]
		});
		

        this.dockedItems = [this.topToolbar];

        this.notesList = new Ext.List({
            store: this.notesStore,
            grouped: true,
            emptyText: '<div style="margin:5px;">No notes cached.</div>',
            onItemDisclosure: true,
            itemTpl: '<div class="list-item-title">{title}</div>' +
                            '<div class="list-item-narrative">{narrative}</div>'

        });

        this.notesList.on('disclose', function (record, index, evt) {
            this.onEditNote(record, index);
        }, this),

        this.items = [this.notesList];

        FlyTalk.views.NotesListView.superclass.initComponent.call(this);
    },

    onSearch: function () {
        Ext.dispatch({
            controller: FlyTalk.controllers.notesController,
            action: 'openSearch'
        });
    },

    onCompose: function (record, index) {
        Ext.dispatch({
            controller: FlyTalk.controllers.notesController,
            action: 'composePost',
            note: record
        });
    },

    refreshColumn: function () {
        this.notesList.refresh();
    }
});